import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../src/components/login.vue'
import { RouterTabRoutes } from 'vue-router-tab'

const importPage = (view) => () => import(`../pages/${view}.vue`)

Vue.use(VueRouter)

const routes = [

      {
        path: '/index', // 默认页和父级路由一致
        name: 'index',
        component: importPage('index'),
        meta: {
          title: '主页', // 页签标题
        },
      },
     {
       path: '/updatePass', // 默认页和父级路由一致
       name: 'updatePass',
       component: importPage('updatePass/updatePass'),
       meta: {
         title: '修改密码', // 页签标题
       },
     },
	 {
	   path: '/my', // 默认页和父级路由一致
	   name: 'my',
	   component: importPage('main/my'),
	   meta: {
	     title: '我的', // 页签标题
	   },
	 },
	 {
	   path: '/payment', // 默认页和父级路由一致
	   name: 'payment',
	   component: importPage('main/payment'),
	   meta: {
	     title: '戍码分期', // 页签标题
	   },
	 },
	 {
	   path: '/paymentInfo', // 默认页和父级路由一致
	   name: 'paymentInfo',
	   component: importPage('main/paymentInfo'),
	   meta: {
	     title: '分期列表', // 页签标题
	   },
	 },
	 {
	   path: '/updateInfo', // 默认页和父级路由一致
	   name: 'updateInfo',
	   component: importPage('main/updateInfo'),
	   meta: {
	     title: '补全信息', // 页签标题
	   },
	 },
	 {
	   path: '/', // 默认页和父级路由一致
	   name: 'main',
	   component: importPage('main/main'),
	   meta: {
	     title: '首页', // 页签标题
	   },
	 },
	 {
	   path: '/page/:id',
	   name: 'Page',
	   component: importPage('Page'),
	   meta: {
	     key: 'path',
	     title(route) {
	       return `Page ${route.params.id}`
	     },
	   },
	 },
  {
    path: '/',
    name: 'login',
    component: Login,
  },
  
]
const router = new VueRouter({
  routes,
})
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err)
}

export default router
